package cn.com.infcn.spider.domain;

import java.util.Date;

import cn.com.infcn.spider.scheduler.Scheduler;

/**
 * 抽象工作类
 * 
 * @author Ansj
 *
 */
public abstract class Job {
	private String _id ;
	private String name;
	private Date startTime;//任务开始时间;
	private Date endTime;//任务结束时间;
	private Date createTime;
	private Date updateTime;
	private String user;
	private int status;// -1 删除 0停止 1运行 2完成

	private String parse; // 解析规则

	private String input;

	private String output;
	
	protected long sleepTime;

	public abstract String getJobType();

	public String getParse() {
		return parse;
	}

	public void setParse(String parse) {
		this.parse = parse;
	}

	/**
	 * 实例化一个调度
	 */
	public abstract Scheduler instanceScheduler();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getInput() {
		return input;
	}

	public void setInput(String input) {
		this.input = input;
	}

	public String getOutput() {
		return output;
	}

	public void setOutput(String output) {
		this.output = output;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getStatusStr() {
		return status2Str(this.status);
	}

	
	
	public String get__id() {
		return _id;
	}

	public void set_id(String _id) {
		this._id = _id;
	}

	public long getSleepTime() {
		return sleepTime;
	}

	public void setSleepTime(long sleepTime) {
		this.sleepTime = sleepTime;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public static String status2Str(Object obj) {

		int status = 0;

		if (obj != null) {
			status = Integer.parseInt(obj.toString());
		}

		switch (status) {
		case -1:
			return "删除";
		case 0:
			return "停止";
		case 1:
			return "运行";
		case 2:
			return "完成";
		default:
			return "unknow";
		}
	}

}
